<?php
  class Window extends Component {
    public $objs = array();    

    function show($id) {
        $html = "<div id=\"" . $this->uuid . "_header\"><a href=\"javascript:void(0)\" style=\"text-decoration: none; color: #444444\" onclick=\"send_event(\\'" . $this->uuid . "\\',\\'close\\',true);\">X</a></div><div id=\"" . $this->uuid . "_body\"></div>";
        parent::show($id,$html);
        echo "el = document.getElementById('" . $this->uuid . "_header');\n";
        echo "el.style.background = '#bebebe';\n";
        echo "el.style.textAlign = 'right';\n";
        echo "el.style.lineHeight = '100%';\n";
        echo "el.style.cursor = 'pointer';\n";
        
        echo "el.onmousedown = function(e) {\n";
        echo "  if (!e) e = window.event;\n";
        echo "  d = document.getElementById('" . $this->uuid . "');\n";
        echo "  dragok = true;\n";
        echo "  sx = e.clientX;\n";
        echo "  sy = e.clientY;\n";
        echo "}\n";
        echo "el.onmouseup = function() {\n";
        echo "  dragok = false;\n";
        echo "  d = '';\n";
        echo "}\n";        
        
        foreach($this->objs as $obj) {
         $obj->show($this->uuid . "_body");
        }
    }
    function add(&$obj) {
       $this->objs[] = $obj;
    }    
    function __construct($uuid) {
      parent::__construct($uuid);
      $this->setBounds(20,40,100,30);
      $this->setStyle("background","#f5f5f5");
      $this->setStyle("border","1px solid #bebebe");
    }
  }

?>
